<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="jquery-3.5.0.js"></script>
    </head>
    <body>
        <div id="result"></div>
        <img src="" width="60%">
        <input type="file" id="files" multiple>
        <input type="button" value="上传" onclick="uploadFile()">

        <script>
            function uploadFile() {
                var formData = new FormData();
                for(var i=0; i < $('#files')[0].files.length; i++){
                    formData.append('files', $('#files')[0].files[i]);
                    console.log($('#files')[0].files[i]);
                }
                console.log(formData);
                // formData.append("file",file);
                $.ajax({
                    type:'post',
                    url:'/uploads',
                    processData: false,
                    contentType: false,
                    data: formData,
                    success: function (msg) {
                        console.log(msg)
                        // $("#result").html(msg)
                        // $("img").attr("src",msg)
                    }
                })
            }
        </script>
    </body>

</html>